package com.situ.web.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.ws.WebEndpoint;
@WebServlet("/timeServlet")
public class TimeServlet extends HttpServlet{
	
	@Override
	public void init(ServletConfig config) throws ServletException {
		super.init(config);
		String maxOnline = config.getInitParameter("maxOnline");
		System.out.println("maxOnline"+maxOnline);
		System.out.println("TimeServlet.init()");
	}

	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		ServletConfig servletConfig = getServletConfig();
		String maxOnline = servletConfig.getInitParameter("maxOnline");
		System.out.println("maxOnline"+maxOnline);
		Date date = new Date();
		SimpleDateFormat simpleDateFormat = 
				new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
		String nowTime = simpleDateFormat.format(date);
		
		PrintWriter printWriter = resp.getWriter();
		printWriter.println("<p>"+nowTime+"</p>");
		printWriter.close();
	}
	@Override
	public void destroy() {
		super.destroy();
		System.out.println("TimeServlet.destroy()");
	}
}
